<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Đặng Khánh Trung
 * Date: 11/2/12
 * Time: 11:33 AM
 * To change this template use File | Settings | File Templates.
 */
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$document = JFactory::getDocument();

$dienbienluongs = $this->get('dienbienluongs');
$pagination = $this->get('pagination');
$session = JFactory::getSession();
$donvi = $this->get('donvi');
$khoi = $this->get('khoi');

$donvilanhdao = VastHelper::getDonViLanhDao();
if (!(JFactory::getUser()->authorise('vast.donvi.quanlyhosocanbo', 'com_vast') && $donvilanhdao->donviid == $donvi->id))
{
    JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_vast&view=vast'));                
}

?>

<div id="crumbs">
    <div style="color: #222222;font-weight: normal;margin: 0;padding: 0">
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=vast') ?>">Trang chủ</a> »
        <span>Cơ cấu tổ chức</span> »
        <?php if (isset($khoi)): ?>        
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=donvitructhuoc&id=' . $khoi->id); ?>"><?php echo $khoi->ten ?></a> »                
        <?php endif; ?>
        <?php if (isset($donvi)): ?>
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=phongtructhuocs&id=' . $donvi->id); ?>"><?php echo $donvi->ten ?></a> »
        <?php endif; ?>
        <span>Lương cán bộ</span>
    </div>
</div>

<div id="main" class="home">
    <h3 class="title green">Tra cứu thông tin lương của phòng <?php echo $donvi->ten; ?></h3>
    <div class="search-form">
        <div class="wide form">
            <form id="commentform" class="commentform" class="form-validate" method="post" action="index.php?option=com_vast&view=dienbienluongcanbodonvis&context=dienbienluongcanbodonvis&donviid=<?php echo JRequest::getInt('donviid'); ?>">
    
                <div class="row">
                    <label style="text-align: left;">Họ tên</label>		
                    <input size="60" maxlength="128" name="hosocanboHoten" id="hosocanboHoten" type="text" value="<?php if ($session->get('dienbienluongcanbodonvis.hoten') !== NULL) echo $session->get('dienbienluongcanbodonvis.hoten'); ?>"/>	
                </div>
    
                <div class="row">
                    <label style="text-align: left;">Giới tính</label>                
                    <select style="width: 25%;" name="hosocanboGioitinh" id="hosocanboGioitinh">
                        <?php if ($session->get('dienbienluongcanbophongs.gioitinh') == 2): ?>
                        <option value="2" selected="selected">-Tất cả-</option>
                        <?php else: ?>
                        <option value="2">-Tất cả-</option>
                        <?php endif; ?>
                        <?php if ($session->get('dienbienluongcanbodonvis.gioitinh') == 1): ?>
                        <option value="1" selected="selected">Nam</option>
                        <?php else: ?>
                        <option value="1">Nam</option>
                        <?php endif; ?>
                        <?php if ($session->get('dienbienluongcanbodonvis.gioitinh') == 0): ?>
                        <option value="0" selected="selected">Nữ</option>
                        <?php else: ?>
                        <option value="0">Nữ</option>
                        <?php endif; ?>
                    </select>    
                </div>
    
                <div class="row buttons">
                    <input type="hidden" name="view" value="dienbienluongcanbodonvis" />
                    <input id="submit" value="Tìm kiếm" type="submit"/>	
                    <?php echo JHtml::_('form.token'); ?>
                </div>
    
            </form>
        </div>
    </div>
    
    <div>
        <table id="rounded-corner">
            <thead>
                <tr>
                    <th scope="col" class="rounded-company"><a href="#hoten">Ngày thay đổi</a></th>
                    <th scope="col" class="rounded-q1" style="width: 70px;"><a href="#bac">Bậc</a></th>
                    <th scope="col" class="rounded-q2"><a href="#heso">Hệ số</a></th>
                    <th scope="col" class="rounded-q3"><a href="#canbo">Cán bộ</a></th>
                    <th scope="col" class="rounded-q4" style="width: 70px;"><a href="#chucnang">Chức năng</a></th>
                </tr>    
    <!--            <tr>
                    <th scope="col" class="rounded-q1" width="30%"><input type="text"/></th>
                    <th scope="col" class="rounded-q1" width="15%"><input type="text"/></th>
                    <th scope="col" class="rounded-q1" width="15%"><input type="text"/></th>
                    <th scope="col" class="rounded-q1" width="20%"><input type="text"/></th>
                    <th scope="col" class="rounded-q1" width="20%"><input type="text"/></th>
                </tr>-->
            </thead>
            <tfoot>
                <tr>
                    <td colspan="4" class="rounded-foot-left">
                        <em>
                        </em>
                    </td>
                    <td class="rounded-foot-right" style="font-size: smaller;">
                    </td>
                </tr>
            </tfoot>
            <tbody>
                <?php if (count($dienbienluongs) > 0) foreach ($dienbienluongs as $item) { ?>
                    <tr>
                        <td>
                            <?= date('d/m/Y', strtotime($item->ngaythaydoi)) ?>
                        </td>
                        <td>
                            <?= $item->bac ?>
                        </td>
                        <td><?= $item->heso ?></td>
                        <td><?= $item->hoten ?></td>
                        <td style="text-align: center;">
                            <?php if (JFactory::getUser()->authorise('vast.hosocanbo.edit', 'com_vast') 
                                || (JFactory::getUser()->authorise('vast.hosocanbo.edit.own', 'com_vast') && $hosocanbo->nguoidung_id == JFactory::getUser()->id)
                                || (JFactory::getUser()->authorise('vast.donvi.quanlyhosocanbo', 'com_vast') && $donvilanhdao->donviid == $donvi->id)): ?>    
                            <a href="<?php echo JRoute::_('index.php?option=com_vast&view=dienbienluongcanbodonvi&layout=edit&dienbienluongid=' . $item->id . '&id=' . $item->hosocanbo_id) . '&donviid=' . $donvi->id; ?>">
                                <img src="<?php echo $this->baseurl . '/components/com_vast/assets/images/update.png' ?>" />                            
                            </a>
                            <?php endif; ?>
                            <?php if (JFactory::getUser()->authorise('vast.hosocanbo.edit', 'com_vast') 
                            || (JFactory::getUser()->authorise('vast.hosocanbo.edit.own', 'com_vast') && $hosocanbo->nguoidung_id == JFactory::getUser()->id)
                            || (JFactory::getUser()->authorise('vast.donvi.quanlyhosocanbo', 'com_vast') && $donvilanhdao->donviid == $donvi->id)): ?>    
                            <a onclick="return confirm('Bạn có chắc muốn xóa diễn biến lương này ?');" href="<?php echo JRoute::_('index.php?option=com_vast&view=dienbienluongcanbodonvi&task=dienbienluongcanbodonvi.delete&dienbienluongid=' . $item->id . '&id=' . $item->hosocanbo_id . '&donviid=' . $donvi->id); ?>">
                                <img src="<?php echo $this->baseurl . '/components/com_vast/assets/images/delete.png' ?>" />                            
                            </a>
                            <?php endif; ?>
                        </td>
                    </tr>
                <?php } ?>
            </tbody>
        </table>
        <div id="tnt_pagination" style="margin-top: 5px;">
        <?php
            echo $pagination->getPagesLinks();
        ?>
        </div>            
    </div>
    <div style="float: left; width: 680px; margin-top: 5px;">
        <?php
        $url = htmlspecialchars($_SERVER['HTTP_REFERER']);
        echo '<a title="Quay lại" href="' . $url . '"><span style="left: 610px; position: relative;">&laquo; Quay lại</span></a>';
        ?>    
    </div>    
    
</div>